#include<QTest> 

#include"Playlist.h"
#include"Song.h"

class TestPlaylist: public QObject{
Q_OBJECT
private:
	Playlist *m_playlist;
private slots:
	void initTestCase(){
		m_playlist = new Playlist;
		qApp->setApplicationName("test");
		Song *song = new Song("song.ogg");
		QVERIFY(song);//This doesn't really belong here...
		m_playlist->add(song);
		QCOMPARE(m_playlist->numSongs(), (unsigned)1);
	}
	
	void cleanupTestCase(){
		m_playlist->clear();
		QVERIFY(m_playlist->isEmpty());
		if(m_playlist)
			delete m_playlist;
	}
	
	void testAddSong(){//Kinda ... Useless, but still.
		QCOMPARE(m_playlist->numSongs(), (unsigned)1);
		Song *song = new Song("song.ogg");
		m_playlist->add(song);
		QCOMPARE(m_playlist->numSongs(), (unsigned)2);
		m_playlist->slotRemoveSong(1);
		QCOMPARE(m_playlist->numSongs(), (unsigned)1);
	}
	
	void testBasics(){
		QVERIFY(!m_playlist->isEmpty());
		QVERIFY(m_playlist->next());
		QVERIFY(m_playlist->previous());
		QCOMPARE(m_playlist->current()->path(), QString("song.ogg"));
		QCOMPARE(m_playlist->song(0)->path(), QString("song.ogg"));
	}
};

QTEST_MAIN(TestPlaylist)
#include"TestPlaylist.moc"
